<template>
  <view>
    <view class="container">
      <view class="tabs-header">
        <up-tabs
          class="up-tabs-content"
          :list="tabsData"
          @click="onTabClick"
          :lineWidth="lineWidth"
          lineColor="#2877FF"
          :activeStyle="activeTabStyle"
          :inactiveStyle="inactiveTabStyle"
          itemStyle="padding-left: 15px; padding-right: 15px; height: 50px;"
        />
      </view>
      <!-- 表单内容 -->
      <u-form class="form-content">
        <!-- 车牌号码输入 -->
        <u-form-item label="车牌号码" class="form-item" label-width="120">
          <u-input
            v-model="formData.plateNumber"
            placeholder="请输入车牌号码"
            class="custom-input"
          />
        </u-form-item>

        <!-- 车牌颜色选择 -->
        <u-form-item label="车牌颜色" class="form-item" label-width="120">
          <view class="arrow-icon-groud">
            <u-input
              class="custom-input"
              v-model="formData.plateColor"
              placeholder="请选择车牌颜色"
              @click="changeOpenCarColor"
            />
            <!-- 向下/向上箭头图标 -->
            <u-icon
              :name="plateColorPickerVisible ? 'arrow-up' : 'arrow-down'"
              size="20"
              class="arrow-icon"
            />
          </view>

          <area-picker
            ref="carPicker"
            :title="title"
            titleColor="#808080"
            titleFontSize="14px"
            cancelType="icon"
            cancelColor="#999999"
            cancleFontSize="28rpx"
            confirmColor="#2877FF"
            confirmFontSize="14px"
            confirmFontWeight="500"
            itemFontSize="14px"
            @onClose="closeCarPicker"
            @onConfirm="confirmCarPicker"
            :pickerList="list"
          />
        </u-form-item>
      </u-form>

      <!-- 查询按钮 -->
      <view class="btn-container">
        <u-button @click="goToquerycert()">立即查询</u-button>
      </view>
      <view
        class="card"
        v-for="(item, index) in carList"
        :key="index"
        @click="goTocertDetails"
      >
        <view class="car-info">
          <view class="car-top">
            <view class="car-top-left">
              <up-icon name="photo"></up-icon>
              <text class="car-number">车牌号码：{{ item.carNumber }}</text>
            </view>
            <view>
              <up-icon name="arrow-right"></up-icon>
            </view>
          </view>

          <view>
            <text class="transport-code"
              >道路运输证号：{{ item.transportCode }}</text
            >
          </view>
        </view>
      </view>
      <view class="btn-container">
        <u-button @click="loadingMore">加载更多</u-button>
      </view>
    </view>
  </view>
</template>
<script>
import { changePlatecolor } from "@/common/util_complete.js";
export default {
  data() {
    return {
      tabsData: [
        { name: "营运车辆", id: "1" },
        { name: "经营业户", id: "2" },
        { name: "从业人员", id: "3" },
      ],
      formData: {
        region: "",
        plateNumber: "",
        plateColor: "",
        transportNumber: "",
      },
      lineWidth: 60,
      activeTabStyle: {
        color: "#2877FF",
        fontSize: "16px",
        fontWeight: "bold",
      },
      userType: "1",
      inactiveTabStyle: {
        color: "#0D1444",
        fontSize: "16px",
        fontWeight: "normal",
      },
      list: [], // 车牌颜色选择
      carList: [
        {
          carNumber: "鄂H0T379",
          transportCode: "荆门420881206832",
        },
        {
          carNumber: "鄂H0T379",
          transportCode: "荆门420881206832",
        },
        {
          carNumber: "鄂H0T379",
          transportCode: "荆门420881206832",
        },
      ],
    };
  },
  onLoad() {
    this.list = changePlatecolor(this.list);
  },
  methods: {
    changeOpenCarColor() {
      this.$refs.carPicker._open();
    },
    //关闭选择器
    closeCarPicker() {
      this.$refs.carPicker._close();
    },
    confirmCarPicker(checkedValue) {
      this.formData.plateColor = checkedValue;
    },

    onTabClick(event, index) {
      this.userType = event.id;
    },
    goTocertDetails() {
      uni.redirectTo({
        url: `/pages/hub_zsyg/cert/querycertdetails?plateNumber=${this.formData.plateNumber}&plateColor=${this.formData.plateColor}&userType=${this.userType}`,
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.container {
  width: 100%;
  padding: 10px;
  background-color: #f3f6fa;
  height: 100vh;
  box-sizing: border-box;
}
.tabs-header {
  background-color: #fff;
  height: 47px;
  margin-bottom: 10px;
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  .up-tabs-content {
    margin-top: 10px;
  }
}

.form-content {
  background-color: #ffffff;
  padding: 0;
  /* 去掉 padding */
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  .form-item {
    padding: 0 10px;
    border-bottom: 1px solid #f1f1f1;
    /* 设置下边框 */
  }
  .custom-input {
    border: none;
    /* 去掉输入框的边框 */
    background-color: transparent;
    /* 使背景透明 */
  }
}
//单独设置箭头图标的样式
.arrow-icon-groud {
  position: relative;
  flex: 1;

  .arrow-icon {
    position: absolute !important;
    right: 20px;
    top: 10px;
  }
}
//按钮样式
.btn-container {
  margin: 30px 0;
  text-align: center;

  width: 100%;
  box-sizing: border-box;
  ::v-deep .u-button--info[data-v-461e713c] {
    width: 100%;
    background-color: #2877ff;
    color: #ffffff;
  }
}

/* 定义卡片的背景、圆角和阴影 */
.card {
  background-color: #fff;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 图标与车辆信息的布局 */
.car-info {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;

  .car-top {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 10px 0;
    border-bottom: 1px solid #f1f1f1;

    margin-bottom: 10px;
    .car-top-left {
      display: flex;
      align-items: center;
      flex: 1;
      .car-number {
        margin-left: 10px;
        font-size: 18px;
        color: #333333;
      }
    }
  }
  .transport-code {
    font-size: 12px;
    color: #79829c;
  }
  .icon {
    width: 40px;
    height: 40px;
  }
}
</style>
